package club.vann.kafka.mock.kafka;

import club.vann.kafka.mock.common.config.AppConfig;
import club.vann.kafka.mock.common.model.consts.ConstantCharacter;

public class KafkaTopicFactory {
  private KafkaTopicFactory() {}

  /** Acceptor Input 数据 */
  public static final String ACCEPTOR_INPUT;

  /** Acceptor Output 数据 */
  public static final String ACCEPTOR_OUTPUT;

  /** MarketPrice汇总数据 */
  public static final String MARKET_PRICE_SUMMARY_OUTPUT;

  /** Pair summary 汇总数据 */
  public static final String PERP_PAIR_SUMMARY_OUTPUT;

  /** 报价操作结果响应 */
  public static final String QUOTE_ACTION_OUTPUT;

  /** 报价市场行情 */
  public static final String QUOTE_MARKET_OUTPUT;

  /** 波动率数据 */
  public static final String REALIZED_VOLATILITY_INPUT;

  /** 策略汇总数据 */
  public static final String STRATEGY_SUMMARY_OUTPUT;

  /** 动态表格数据 */
  public static final String TABLE_DATA_OUTPUT;

  /** 成交数据 */
  public static final String TRADE_EVENT_OUTPUT;

  /** zhouyi系统重启信息的 Topic */
  public static final String ZHOUYI_INIT_OUTPUT;

  public static final String STRATEGY_PARENT_ACTION_OUTPUT;

  public static final String TRANSFER_OUTPUT;

  static {
    ACCEPTOR_INPUT = addPrefix(ConstantTopic.TOPIC_ACCEPTOR_INPUT);
    ACCEPTOR_OUTPUT = addPrefix(ConstantTopic.TOPIC_ACCEPTOR_OUTPUT);
    MARKET_PRICE_SUMMARY_OUTPUT = addPrefix(ConstantTopic.TOPIC_MARKET_PRICE_SUMMARY_OUTPUT);
    PERP_PAIR_SUMMARY_OUTPUT = addPrefix(ConstantTopic.TOPIC_PERP_PAIR_SUMMARY_OUTPUT);
    QUOTE_ACTION_OUTPUT = addPrefix(ConstantTopic.TOPIC_QUOTE_ACTION_OUTPUT);
    QUOTE_MARKET_OUTPUT = addPrefix(ConstantTopic.TOPIC_QUOTE_MARKET_OUTPUT);
    REALIZED_VOLATILITY_INPUT = addPrefix(ConstantTopic.TOPIC_REALIZED_VOLATILITY_INPUT);
    STRATEGY_SUMMARY_OUTPUT = addPrefix(ConstantTopic.TOPIC_STRATEGY_SUMMARY_OUTPUT);
    TABLE_DATA_OUTPUT = addPrefix(ConstantTopic.TOPIC_TABLE_DATA_OUTPUT);
    TRADE_EVENT_OUTPUT = addPrefix(ConstantTopic.TOPIC_TRADE_EVENT_OUTPUT);
    ZHOUYI_INIT_OUTPUT = addPrefix(ConstantTopic.TOPIC_ZHOUYI_INIT_OUTPUT);
    STRATEGY_PARENT_ACTION_OUTPUT = addPrefix(ConstantTopic.TOPIC_STRATEGY_PARENT_ACTION_OUTPUT);
    TRANSFER_OUTPUT = addPrefix(ConstantTopic.TOPIC_TRANSFER_OUTPUT);
  }

  private static String addPrefix(String topic) {
    if (AppConfig.config.getKafkaTopicPrefix() == null) {
      return topic;
    }
    return String.join(ConstantCharacter.DOT, AppConfig.config.getKafkaTopicPrefix(), topic);
  }
}
